cmake_minimum_required(VERSION 3.16)
project(subdirectoies VERSION 1.0 LANGUAGES C CXX)

function(test1)
    #CMAKE_SOURCE_DIR: top-most directory of the source tree
    message("top: CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
    #CMAKE_BINARY_DIR: top-most directory of the build tree
    message("top: CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
    #CMAKE_CURRENT_SOURCE_DIR: the directory of the CMakeLists.txt file currently being processed by CMake
    message("top: CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
    #CMAKE_CURRENT_BINARY_DIR: the build directory corresponding  to the CMakeListx.txt file currently being processed by CMake
    message("top: CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")

    #add_subdirectory()：引入新的scope，和block()的效果是一样的
    set(variable hello)
    message("top variable: ${variable}")
    add_subdirectory(sub1)
    message("top variable: ${variable}")
endfunction()


function(test2)
#include()：不引入新的scope，相当于内容在引用出展开
#CMAKE_CURRENT_LIST_DIR: 当前正在被处理的CMakeLists.txt所在的目录
#CMAKE_CURRENT_LIST_FILE: 当前正在被处理的CMakeLists.txt
#CMAKE_CURRENT_LIST_LINE: 当前正在被处理的CMakeLists.txt所在的执行行
    include(test.cmake)
endfunction()

function(test3)
    add_subdirectory(sub2)
endfunction()


test3()














